import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _class;

import React from 'react';
import { Table } from 'antd';
import { Bind } from 'lodash-decorators';
import intl from 'utils/intl';
import { operatorRender, yesOrNoRender } from 'utils/renderer';
import { Button as ButtonPermission } from 'components/Permission';
import styles from "./index.less?modules";
var commonPrompt = 'cpaas.common';
var List = (_dec = Bind(), (_class = /*#__PURE__*/function (_React$Component) {
  _inherits(List, _React$Component);

  var _super = _createSuper(List);

  function List() {
    var _this;

    _classCallCheck(this, List);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _super.call.apply(_super, [this].concat(args));
    _this.defaultTableRowKey = 'id';
    return _this;
  }

  _createClass(List, [{
    key: "onCell",
    value: function onCell() {
      return {
        style: {
          overflow: 'hidden',
          maxWidth: 220,
          textOverflow: 'ellipsis',
          whiteSpace: 'nowrap'
        },
        onClick: function onClick(e) {
          var target = e.target;

          if (target.style.whiteSpace === 'normal') {
            target.style.whiteSpace = 'nowrap';
          } else {
            target.style.whiteSpace = 'normal';
          }
        }
      };
    }
  }, {
    key: "render",
    value: function render() {
      var _this2 = this;

      var _this$props = this.props,
          content = _this$props.content,
          tenantLoading = _this$props.tenantLoading,
          tenantPagination = _this$props.tenantPagination,
          _this$props$onTenantP = _this$props.onTenantPageChange,
          onTenantPageChange = _this$props$onTenantP === void 0 ? function (e) {
        return e;
      } : _this$props$onTenantP,
          _this$props$onHandleT = _this$props.onHandleToDetails,
          onHandleToDetails = _this$props$onHandleT === void 0 ? function (e) {
        return e;
      } : _this$props$onHandleT;
      var columns = [{
        title: intl.get('ciam.tenantMenu.model.tenantMenu.tenantCode').d('租户编码'),
        width: 200,
        dataIndex: 'tenantNum'
      }, {
        title: intl.get('ciam.tenantMenu.model.tenantMenu.tenantName').d('租户名称'),
        dataIndex: 'tenantName'
      }, {
        title: intl.get('ciam.tenantMenu.model.tenantMenu.customMenuFlag').d('包含自定义菜单'),
        dataIndex: 'customMenuFlag',
        render: yesOrNoRender,
        width: 120,
        align: 'center'
      }, {
        title: intl.get("".concat(commonPrompt, ".table.column.option")).d('操作'),
        width: 120,
        fixed: 'right',
        render: function render(text, record) {
          var path = _this2.props.path;
          var operators = [];
          operators.push({
            key: 'detail',
            ele: /*#__PURE__*/React.createElement(ButtonPermission, {
              type: "text",
              permissionList: [{
                code: "".concat(path, "/edit"),
                type: 'button',
                meaning: '代理-编辑'
              }],
              onClick: function onClick() {
                onHandleToDetails(record);
              }
            }, intl.get('cpaas.common.button.details').d('查看详情')),
            len: 4,
            title: intl.get('cpaas.common.button.details').d('查看详情')
          });
          return operatorRender(operators);
        }
      }];
      return /*#__PURE__*/React.createElement(Table, {
        bordered: true,
        rowKey: "tenantId",
        rowClassName: styles['ciam-tenant-table'],
        loading: tenantLoading,
        dataSource: content,
        columns: columns,
        pagination: tenantPagination,
        onChange: onTenantPageChange
      });
    }
  }]);

  return List;
}(React.Component), (_applyDecoratedDescriptor(_class.prototype, "onCell", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "onCell"), _class.prototype)), _class));
export { List as default };